//----------------------------------------------------------------------------
// View 'Datum selecteren'
//----------------------------------------------------------------------------
var viewDatePicker = Titanium.UI.createView({
   backgroundColor : 'transparent',
   width : '100%',
   height : '100%'
});

var selectedDate = new Date();

//----- header
if (isIpad()) {
   var viewDatePickerHeader = Titanium.UI.createView({
      top : '110',
      backgroundColor : donkergroen,
      width : '300',
      height : '35',
      borderRadius : '2',
      borderColor : donkergroen
   });
}
else if (isIphone()) {
   var viewDatePickerHeader = Titanium.UI.createView({
      top : '15',
      backgroundColor : donkergroen,
      width : '300',
      height : '35',
      borderRadius : '2',
      borderColor : donkergroen
   });
}
viewDatePickerHeader.add(Titanium.UI.createLabel({
   textAlign : Ti.UI.TEXT_ALIGNMENT_LEFT,
   font : {
      fontSize : 12,
      fontWeight : 'bold',
      fontFamily : customFont
   },
   color : wit,
   top : '5',
   left : '5',
   right : '5',
   backgroundColor : donkergroen,
   text : T_HHRECEPT_DLG_DATEPICKER_TITLE
}));

var btnPickDate = Titanium.UI.createButton({
   top : '1',
   right : '1',
   width : '100',
   height : '25',
   font : {
      fontSize : 14,
      fontWeight : 'bold',
      fontFamily : customFont
   },
   color : wit,
   backgroundColor : donkergroen,
   backgroundImage : 'images/backgrounds/bg-donkergroen.png',
   title : T_HHRECEPT_DLG_DATEPICKER_SELECT
});
btnPickDate.addEventListener('click', function(e) {
   var d = selectedDate.getDate() + "-" + (selectedDate.getMonth() + 1) + "-" + selectedDate.getFullYear();
   log("Geselecteerde datum: " + d);
   tfGebDatum.value = d;
   winHHRecept.remove(viewDatePicker);
});

viewDatePickerHeader.add(btnPickDate);

//----- content
if (isIphone()) {
   var viewDatePickerContent = Titanium.UI.createView({
      backgroundColor : wit,
      top : '40',
      width : '300',
      height : '215',
      borderRadius : '2',
      borderColor : donkergroen
   });
}
else if (isIpad()) {
   var viewDatePickerContent = Titanium.UI.createView({
      backgroundColor : wit,
      top : '135',
      width : '300',
      height : '215',
      borderRadius : '2',
      borderColor : donkergroen
   });
}

var aDate = new Date();
var today = new Date(aDate.getFullYear(), aDate.getMonth(), aDate.getDate());
var datePicker = Ti.UI.createPicker({
   top : '0',
   width : '100%',
   type : Ti.UI.PICKER_TYPE_DATE,
   minDate : new Date(1900, 0, 1),
   maxDate : today,
   value : today
});
datePicker.addEventListener('change', function(e) {
   selectedDate = e.value;
});

datePicker.selectionIndicator = true;
viewDatePickerContent.add(datePicker);
viewDatePicker.add(viewDatePickerHeader, viewDatePickerContent);